﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace PuzzleDulex.bamboo
{
    public enum TILE
    {
        TL_SPACE,
        TL_1,
        TL_2,
        TL_3,
        TL_4,
        TL_5,
        TL_6,
        TL_7,
        TL_8

    };

    public class PuzzleState
    {

        public const int BOARD_WIDTH = 3;
        public const int BOARD_HEIGHT = 3;

        public const int GM_TILE = -1;
        public const int GM_SPACE = 0;
        public const int GM_OFF_BOARD = 1;

        // data
        //public static TILE[] g_goal = new TILE[]
        //{ 
        //    TILE.TL_1,
        //    TILE.TL_2,
        //    TILE.TL_3,
        //    TILE.TL_8,
        //    TILE.TL_SPACE,
        //    TILE.TL_4,
        //    TILE.TL_7,
        //    TILE.TL_6,
        //    TILE.TL_5,
        //};


        public static TILE[] g_goal = new TILE[]
        { 
            TILE.TL_1,
	        TILE.TL_2,
	        TILE.TL_3,
	        TILE.TL_8,
	        TILE.TL_5,
	        TILE.TL_4,
	        TILE.TL_7,
	        TILE.TL_6,
	        TILE.TL_SPACE,
        };

        //public static TILE[] g_start = new TILE[]
        //{
        // TILE.TL_2 ,
        // TILE.TL_8 ,
        // TILE.TL_3 ,
        // TILE.TL_1 ,
        // TILE.TL_SPACE ,
        // TILE.TL_6 ,
        // TILE.TL_4 ,
        // TILE.TL_7 ,
        // TILE.TL_5 ,
        //};

        public static TILE[] g_start = new TILE[]
        {
            TILE.TL_1,
	        TILE.TL_2,
	        TILE.TL_3,
	        TILE.TL_SPACE,
	        TILE.TL_8,
	        TILE.TL_4,
	        TILE.TL_7,
	        TILE.TL_6,
	        TILE.TL_5,
        };


        public TILE[] tiles;


        // member functions

        public PuzzleState()
        {
            //memcpy( tiles, g_goal, sizeof( TILE ) * BOARD_WIDTH * BOARD_HEIGHT );	
            tiles = new TILE[BOARD_HEIGHT * BOARD_HEIGHT];
        }

        public PuzzleState(TILE[] param_tiles)
        {
            //memcpy( tiles, param_tiles, sizeof( TILE ) * BOARD_WIDTH * BOARD_HEIGHT );
            tiles = new TILE[BOARD_HEIGHT * BOARD_HEIGHT];
            for (int i = 0; i < param_tiles.Length; i++)
            {
                tiles[i] = param_tiles[i];
            }

        }

        /// <summary>
        /// Check if Game Finish
        /// </summary>
        /// <param name="nodeGoal"></param>
        /// <returns></returns>
        //public bool IsGoal(PuzzleState nodeGoal)
        //{
        //    return IsSameState(nodeGoal);
        //}

        //public bool IsSameState(PuzzleState rhs)
        //{

        //    for (int i = 0; i < (BOARD_HEIGHT * BOARD_WIDTH); i++)
        //    {
        //        if (tiles[i] != rhs.tiles[i])
        //        {
        //            return false;
        //        }
        //    }

        //    return true;

        //}

    }

}
